
#ifndef VIDEOINIT_H_
#define VIDEOINIT_H_

void openGLClear() {
	glClearColor(17,28,26,31);
	glClearPolyID(63);
	glClearDepth(0x7FFF);
}

void openGLViewport() {
	glViewport(0,0,SCREEN_WIDTH-1,SCREEN_HEIGHT-1);
}

void openGLInit() {
	glInit();

	glEnable(GL_ANTIALIAS);
	glEnable(GL_TEXTURE_2D);

	openGLClear();

	openGLViewport();
}

void openGLPerspectiveInit() {
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(70, SCREEN_WIDTH / SCREEN_HEIGHT, 0.1, 100);

	glMatrixMode(GL_MODELVIEW);
}

void openGLMaterialInit() {
	glMaterialf(GL_AMBIENT, RGB15(8,8,8));
	glMaterialf(GL_DIFFUSE, RGB15(8,8,8));
	glMaterialf(GL_SPECULAR, RGB15(8,8,8));
	glMaterialf(GL_EMISSION, RGB15(16,16,16));

	glMaterialShinyness();
}

void openGLLightInit() {
	glPolyFmt(POLY_ALPHA(31) | POLY_CULL_FRONT | POLY_FORMAT_LIGHT0 | POLY_FORMAT_LIGHT1 | POLY_FORMAT_LIGHT2);

	glLight(0, RGB15(31,31,31) ,-1, 0, 0);
	glLight(1, RGB15(31,31,31) , 0,-1, 0);
	glLight(2, RGB15(31,31,31) , 0,	0,-1);

	glColor3f(1.0f,1.0f,1.0f);
}

void initVideoMode() {
	videoSetMode(MODE_0_3D);
	videoSetModeSub(MODE_0_2D);
	vramSetBankA(VRAM_A_TEXTURE);
	vramSetBankB(VRAM_B_MAIN_SPRITE);
	vramSetBankD(VRAM_D_SUB_SPRITE);

	openGLInit();

	oamInit(&oamMain, SpriteMapping_1D_128, false);
	oamInit(&oamSub, SpriteMapping_1D_128, false);

	initGFX();
}

#endif /* VIDEOINIT_H_ */
